
-module(numer).
-export([toBin/1,toHex/1]).


toBin(N) -> toBase(N, 2);

toHex(N) -> toBase(N, 16).

digit(M) -> [lists:nth(M+1, "0123456789ABCDEF")].

toBase(N, B) when N < B, B < 17
  -> digit(N);
toBase(N, B)
  -> toBase(N div B, B) ++ digit(N rem B).

